﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace PrintService
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            try
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                new PrintService()
                };

                if (AppDomain.CurrentDomain != null)
                    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                ServiceBase.Run(ServicesToRun);
            }
            catch (Exception e)
            {
                 LogHelper.LogInfo(e.Message);
            }
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                Exception ex = e.ExceptionObject as Exception;

                if (ex != null)
                    LogHelper.LogInfo(ex.Message);
                else
                    LogHelper.LogInfo("Unhandled Exception no details available");
            }
            finally
            {
            }
        }
    }
}
